package com.test.wog.service;

import com.alibaba.fastjson.JSONArray;
import com.test.wog.bean.Node;
import com.test.wog.dao.NodeDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * @author: LX
 * @createDate: 2020-01-26
 * @desc: 关键节点服务
 */
@Service
public class NodeService {
    @Autowired
    private NodeDAO nodeDAO;

    /*根据POI名字进行查询*/
    public String getNodeByName(String name){
        List<Node> nodeList = nodeDAO.getNodeByName(name);
        String jsonString = JSONArray.toJSON(nodeList).toString();
        return jsonString;
    }

    /*根据POI类型进行查询*/
    public String getNodeByType(String type){
        List<Node> nodeList = nodeDAO.getNodeByType(type);
        String jsonString = JSONArray.toJSON(nodeList).toString();
        return jsonString;
    }

    /*根据经纬度查询最近的一个POI*/
    public String getNodeByLoc(double lon, double lat){
        List<Node> nodeList = nodeDAO.getNodeByLoc(lon, lat);
        String jsonString = JSONArray.toJSON(nodeList).toString();
        return jsonString;
    }


    public int insertNode(){
        return nodeDAO.insertNode();
    }
}
